package zlx.controller;

import com.zlx.pojo.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@Controller
public class DeptController {
    @Autowired
    private RestTemplate restTemplate;
    public static  final  String Rest_URL="http://127.0.0.1:8001";

    @RequestMapping("/Consumer/dept/get/{id}")
    public Dept get(@PathVariable long id) {
        return restTemplate.getForObject(Rest_URL + "/queryById/" + id, Dept.class);
    }
    @RequestMapping("Consumer/dept/add")
    public Boolean add(Dept dept)
    {
        return restTemplate.postForObject(Rest_URL+"/dept/add",dept,Boolean.class);

    }
    @RequestMapping("Consumer/query")
    public List query()
    {
        return restTemplate.getForObject(Rest_URL+"/dept/query", List.class);
    }
}
